import Vue from 'vue'
import Router from 'vue-router'
import resource from 'vue-resource'
import Login from "../components/Login"
import Index from "../components/Index"
import UserShow from "../components/user/UserShow"
import UserEdit from "../components/user/UserEdit";
import BlogEdit from "../components/blog/BlogEdit";
import BlogShow from "../components/blog/BlogShow";
import BlogAdd from "../components/blog/BlogAdd";
import BlogApi from "../components/api/BlogApi";

Vue.use(Router)
Vue.use(resource)

// 解决vue-router 在3.0版本以上重复点菜单报错的问题
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}

export default new Router({
  routes: [
    {
      path: '/',
      name: 'login',
      component: Login
    },
    {
      path: '/index',
      name: 'index',
      component: Index
    },
    {
      path: '/user/show',
      name: 'show-user',
      component: UserShow
    },
    {
      path: '/user/edit',
      name: 'user-edit',
      component: UserEdit
    },
    {
      path: '/blog/show',
      name: 'show-blog',
      component: BlogShow
    },{
      path: '/blog/add',
      name: 'add-blog',
      component: BlogAdd
    },
    {
      path: '/blog/edit',
      name: 'blog-edit',
      component: BlogEdit
    },
    {
      path: '/blog/api',
      name: 'blog-api',
      component: BlogApi
    }
  ],
  mode: "history"
})
